<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<input type="text" id="numID" />
		<input type="button" id="btnID" onclick="Cai()" value="猜" />
		<span id="spanID">猜吧</span>

		<script>
			var result = parseInt(Math.random() * 100 + 1);
			console.log(result);
			function Cai() {
				var num = document.getElementById("numID").value;

				var span = document.getElementById("spanID");
				if (num > result) {
					span.innerHTML = "大了";
				} else if (num < result) {
					span.innerHTML = "小了";
				} else {
					span.innerHTML = "猜对啦！";
				}
				if (isNaN(num) == true) {
					span.innerHTML = "请输入数字";
				}
			}
		</script>
	</body>
</html>
